package com.group.yztcedu.playlive.main.me;


import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.group.yztcedu.playlive.R;
import com.group.yztcedu.playlive.main.me.View.MeAccountActivity;
import com.group.yztcedu.playlive.main.me.View.MeFollowActivity;
import com.group.yztcedu.playlive.main.me.View.MeManagingroomsActivity;
import com.group.yztcedu.playlive.main.me.View.MePhoneActivity;
import com.group.yztcedu.playlive.main.me.View.MePlaybackActivity;
import com.group.yztcedu.playlive.main.me.View.MeRechargeActivity;
import com.group.yztcedu.playlive.main.me.View.MeRecordActivity;
import com.group.yztcedu.playlive.main.me.View.MeSetActivity;
import com.group.yztcedu.playlive.main.me.View.MeSettingActivity;
import com.group.yztcedu.playlive.main.me.View.MeStatisticsActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * A simple {@link Fragment} subclass.
 */
public class MeFragment extends Fragment {


    @BindView(R.id.me_head_logo)
    ImageView meHeadLogo;
    @BindView(R.id.me_head_live)
    TextView meHeadLive;
    @BindView(R.id.me_head_name)
    TextView meHeadName;
    @BindView(R.id.me_head_setlist)
    LinearLayout meHeadSetlist;
    @BindView(R.id.me_head_coinnumb)
    TextView meHeadCoinnumb;
    @BindView(R.id.me_head_giftnumb)
    TextView meHeadGiftnumb;
    @BindView(R.id.me_head_recharge)
    LinearLayout meHeadRecharge;
    @BindView(R.id.me_list_account)
    RelativeLayout meListAccount;
    @BindView(R.id.me_list_Managingrooms)
    RelativeLayout meListManagingrooms;
    @BindView(R.id.me_list_follow)
    RelativeLayout meListFollow;
    @BindView(R.id.me_list_Statistics)
    RelativeLayout meListStatistics;
    @BindView(R.id.me_list_playback)
    RelativeLayout meListPlayback;
    @BindView(R.id.me_list_Record)
    RelativeLayout meListRecord;
    @BindView(R.id.me_list_phone)
    RelativeLayout meListPhone;
    @BindView(R.id.me_list_set)
    RelativeLayout meListSet;

    public MeFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_me, container, false);
        ButterKnife.bind(this, view);
        SharedPreferences sp = getActivity().getSharedPreferences("user", Context.MODE_PRIVATE);
        if(sp!=null){
            Glide.with(getActivity()).load(sp.getString("Imageuri",null)).into(meHeadLogo);
            meHeadName.setText(sp.getString("username",null));
        }else{
            meHeadLogo.setImageResource(R.mipmap.ic_launcher);
            meHeadName.setText("YT-s");
        }
        return view;
    }

    @OnClick({R.id.me_head_setlist, R.id.me_head_recharge, R.id.me_list_account, R.id.me_list_Managingrooms, R.id.me_list_follow, R.id.me_list_Statistics, R.id.me_list_playback, R.id.me_list_Record, R.id.me_list_phone, R.id.me_list_set})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.me_head_setlist:
                //activity
                startActivity(new Intent(getActivity(), MeSetActivity.class));
                break;
            case R.id.me_head_recharge:
                //activity
                startActivity(new Intent(getActivity(), MeRechargeActivity.class));
                break;
            case R.id.me_list_account:
                //activity
                startActivity(new Intent(getActivity(), MeAccountActivity.class));
                break;
            case R.id.me_list_Managingrooms:
                //activity
                startActivity(new Intent(getActivity(), MeManagingroomsActivity.class));
                break;
            case R.id.me_list_follow:
                //activity
                startActivity(new Intent(getActivity(), MeFollowActivity.class));
                break;
            case R.id.me_list_Statistics:
                //activity
                startActivity(new Intent(getActivity(), MeStatisticsActivity.class));
                break;
            case R.id.me_list_playback:
                //activity
                startActivity(new Intent(getActivity(), MePlaybackActivity.class));
                break;
            case R.id.me_list_Record:
                //activity
                startActivity(new Intent(getActivity(), MeRecordActivity.class));
                break;
            case R.id.me_list_phone:
                //activity
                startActivity(new Intent(getActivity(), MePhoneActivity.class));
                break;
            case R.id.me_list_set:
                //activity
                startActivity(new Intent(getActivity(), MeSettingActivity.class));
                break;
        }
    }
}
